package com.fuh.study.异常;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

class Annoyance extends Exception {
}

class Sneeze extends Annoyance {
}

class Human {

    public static void main(String[] args) {
        int a = a();
        System.out.println(a);
    }

    public static int a() {
        int result = -1;
        try {
            try {
                throw new Sneeze();
            } catch (Annoyance a) {
                System.out.println("Caught Annoyance");
                throw a;
            }
        } catch (Sneeze s) {
            System.out.println("Caught Sneeze");
            result = 1;
            return 1;
        } finally {
            result = 99;
            System.out.println("Hello World!");
        }
    }

    public void automaticallyCloseResource() {
        File file = new File("./tmp.txt");
        try (FileInputStream inputStream = new FileInputStream(file)) {
            // use the inputStream to read a file
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }





}